﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace CommonBase.ConvertHelp
{
    public class CmdToStringConverter : IValueConverter
    {
        #region Converter

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string strCmd = "XX";
            if (value!=null) 
            {
                int _TypeV=System.Convert.ToInt32(value);
                if (_TypeV == System.Convert.ToInt32(CmdSendType.None))
                {
                    strCmd = "无操作";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.Update)) 
                {
                    strCmd = "更新";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.Back))
                {
                    strCmd = "回退";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.close))
                {
                    strCmd = "关闭";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.Start))
                {
                    strCmd = "启动";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.Maintenance))
                {
                    strCmd = "维护";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.Cancel))
                {
                    strCmd = "取消维护";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.uploadLog))
                {
                    strCmd = "上传日志";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendType.ChangeIpAddress))
                {
                    strCmd = "更新服务器地址";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendResultType.None))
                {
                    strCmd = "无操作";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendResultType.Success))
                {
                    strCmd = CommonStaticModel.LastCmdType+"操作成功";
                }
                else if (_TypeV == System.Convert.ToInt32(CmdSendResultType.Fail))
                {
                    strCmd = CommonStaticModel.LastCmdType + "操作失败";
                }
            }
            
            return strCmd;

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
        #endregion

    }
}
